package dal.datastore;

import java.util.ArrayList;

public class Database {

	private String name;

	private ArrayList<Table> tables;

	public Database(String name, ArrayList<Table> tables) {
		super();
		this.name = name;
		this.tables = tables;
	}

	public Database(String name) {
		super();
		this.name = name;
	}

	public boolean addTable(Table table) {
		if (this.tables == null) {
			this.tables = new ArrayList<>();
			this.tables.add(table);
			return true;
		}
		this.tables.add(table);
		return true;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public ArrayList<Table> getTables() {
		return tables;
	}

	public void setTables(ArrayList<Table> tables) {
		this.tables = tables;
	}

	@Override
	public String toString() {
		return String.format("(name=%s, tables=%s)", name, tables.toString());
	}

	@Override
	public boolean equals(Object obj) {
		return this.name.equalsIgnoreCase(((Database) obj).getName());
	}

}
